// -----------------------------------------------
// Author:     code34 nicolas_boiteux@yahoo.fr
// Edited by:  Neumatic
// Warcontext: Create an ammobox near player position
// -----------------------------------------------

private ["_crate","_position"];

_crate = nearestObjects [player, ["TKVehicleBox_EP1"], 80];

if (count _crate > 0) exitWith {};

wcgarbage = ["Build an ammocrate", "Wait while the building of ammocrate", "The ammocrate will appear near you in few seconds.", 3] spawn WC_fnc_playerhint;
sleep 3;

_position = (getPosATL player) findEmptyPosition [10, 300];
if (_position select 0 == 0) then {
	diag_log "WARCONTEXT: CANNOT FIND EMPTY POSITION FOR CREATE AMMOBOX";
} else {
	wcgarbage = [_position, "base"] spawn WC_fnc_createammobox;
};